package mysql.cs.command;

import mysql.Commond;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * 1              [03] COM_QUERY
 * string[EOF]    the query the server shall execute
 * @ClassName QueryCommand
 * @Description TODO
 * @Author fengk
 * @Date 2018/8/29
 */

public class QueryCommand extends Commond {
    private String queryString;
    public QueryCommand(){
        setCommand((byte)0x03);
    }
    @Override
    public byte[] decode() throws IOException{
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(getCommand());
        out.write(getQueryString().getBytes("UTF-8"));// 链接建立时默认指定编码为UTF-8
        return out.toByteArray();
    }

    public String getQueryString() {
        return queryString;
    }

    public void setQueryString(String queryString) {
        this.queryString = queryString;
    }
    //不可能执行
    @Override
    public void encode(byte[] data){
    }
}
